﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <script src="js/0_common/jquery.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<style>
    .fgsq .layui-form-select .layui-input {
        padding-right: 0 !important;
    }
</style>
<body class="fgsq">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>企业复工复产服务</legend>
</fieldset>

<form class="layui-form" lay-filter="form-test" action=""   id="example" method="post">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
        <legend>附件上传</legend>
        <h4 style="margin: 15px 28px;color: red">友情提示：上传的照片需要盖公章！</h4>
        <div class="layui-form-item">
            <label class="layui-form-label">复工服务表</label>
            <div class="layui-input-block">
                <input type="text" name="zd13" id="input1" lay-verify="title" placeholder="上传最大为2M，多个文件可压缩后上传" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 26.5%;" readonly="readonly">
                <button type="button" class="layui-btn" id="test1"><i class="layui-icon"></i>上传文件</button>
             </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">复工人员登记表</label>
            <div class="layui-input-block">
                <input type="text" name="zd41" id="input41" lay-verify="title" placeholder="上传最大为5M，多个文件可压缩后上传" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 26.5%;"  readonly="readonly">
                <button type="button" class="layui-btn" id="test41"><i class="layui-icon"></i>上传文件</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">企业疫情防控预案</label>
            <div class="layui-input-block">
                <input type="text" name="zd14" id="input2" lay-verify="title" placeholder="上传最大为5M，多个文件可压缩后上传" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 26.5%;"   readonly="readonly">
                <button type="button" class="layui-btn" id="test2"><i class="layui-icon"></i>上传文件</button>
             </div>
        </div>
        <!--<div class="layui-form-item">
            <label class="layui-form-label">企业防护物资储备情况</label>
            <div class="layui-input-block">
                <input type="text" name="zd15" id="input3" lay-verify="title" placeholder="允许上传大小为2M" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 26.5%;" >
                <button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>上传文件</button>
            </div>
        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">承诺书</label>-->
<!--            <div class="layui-input-block">-->
<!--                <input type="text" name="zd16" id="input4" lay-verify="title" placeholder="上传最大为2M，多个文件可压缩后上传" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 26.5%;"   readonly="readonly">-->
<!--                <button type="button" class="layui-btn" id="test4"><i class="layui-icon"></i>上传文件</button>-->
<!--             </div>-->
<!--        </div>-->
        <div class="layui-form-item">
            <label class="layui-form-label">企业防护物资储备情况</label>
            <div class="layui-input-block">
                <input type="text" name="zd24" id="input55" lay-verify="title" placeholder="上传最大为2M，多个文件可压缩后上传" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 26.5%;"  readonly="readonly" >
                <button type="button" class="layui-btn" id="test55"><i class="layui-icon"></i>上传文件</button>
             </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">贵单位在复工过程中是否存在难点或问题</label>
            <div class="layui-input-block">
                <textarea type="text" id="zd88" name="zd88" lay-verify="" autocomplete="off" placeholder="" class="layui-input" style="display: initial;width: 40%;height:200px;"></textarea>
            </div>
        </div>


<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">单位出入口照片<span style="color: red">*</span>(必传)</label>-->
<!--            <div class="layui-upload">-->
<!--                <button type="button" class="layui-btn" id="test5">多图片上传</button>-->
<!--                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 30%; margin-left: 10%">-->
<!--                    预览图：-->
<!--                    <div class="layui-upload-list" id="demo5"></div>-->
<!--                </blockquote>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">办公区照片<span style="color: red">*</span>(必传)</label>-->
<!--            <div class="layui-upload">-->
<!--                <button type="button" class="layui-btn" id="test6">多图片上传</button>-->
<!--                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 30%; margin-left: 10%">-->
<!--                    预览图：-->
<!--                    <div class="layui-upload-list" id="demo6"></div>-->
<!--                </blockquote>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">食堂照片</label>-->
<!--            <div class="layui-upload">-->
<!--                <button type="button" class="layui-btn" id="test7">多图片上传</button>-->
<!--                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 30%; margin-left: 10%">-->
<!--                    预览图：-->
<!--                    <div class="layui-upload-list" id="demo7"></div>-->
<!--                </blockquote>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">应急物资照片<span style="color: red">*</span>(必传)</label>-->
<!--            <div class="layui-upload">-->
<!--                <button type="button" class="layui-btn" id="test8">多图片上传</button>-->
<!--                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 30%; margin-left: 10%">-->
<!--                    预览图：-->
<!--                    <div class="layui-upload-list" id="demo8"></div>-->
<!--                </blockquote>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">物资订单照片</label>-->
<!--            <div class="layui-upload">-->
<!--                <button type="button" class="layui-btn" id="test9">多图片上传</button>-->
<!--                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 30%; margin-left: 10%">-->
<!--                    预览图：-->
<!--                    <div class="layui-upload-list" id="demo9"></div>-->
<!--                </blockquote>-->
<!--            </div>-->
<!--        </div>-->

        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-top: 5%">
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <button class="layui-btn" lay-submit="" lay-filter="demo1" id="tjsb">提交材料</button>
                <!--            <button class="layui-btn" lay-submit="" lay-filter="demo1">下一步</button>-->
            </div>
        </div>
    </fieldset>
</form>

<ul class="layui-timeline" style="display: block" id="time">

</ul>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/constants.js"></script>
<script src="js/0_common/jquery.min.js"></script>
<script src="layui/jquery.serializejson.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var ctx = Constants.path;
    var file = ctx+"FUGONGP/"
    var qyid = localStorage.getItem('qyid');

    $("#ggyqyg").mouseover(function () {
        document.getElementById('ggyqwz').style.display=''
    }).mouseout(function () {
        document.getElementById('ggyqwz').style.display='none'
    });

    $("#ggyqfk").mouseover(function () {
        document.getElementById('ggyqfkwz').style.display=''
    }).mouseout(function () {
        document.getElementById('ggyqfkwz').style.display='none'
    });
    checkStatus();
    var currentEnterprise;
    layui.use(['form', 'layedit', 'laydate','upload'], function(){
        var test5 = "",test6 = "",test7 = "",test8 = "",test9 = "";

        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate,
            upload = layui.upload
        $.ajax({
            type: "get",
            url: ctx + "pb/qysqbs/findall",
            data:{
                "qyid":qyid
            },
            async: false,
            success: function(res) {
                if (res.data.length > 0) {
                    var lastIndex = res.data.length - 1;
                    var currentTable = res.data[lastIndex];
                    // f(currentTable.zd17,"demo5")
                    // f(currentTable.zd18,"demo6")
                    // f(currentTable.zd19,"demo7")
                    // f(currentTable.zd20,"demo8")
                    // f(currentTable.zd21,"demo9")
                    test5 = currentTable.zd17
                    test6 = currentTable.zd18;
                    test7 = currentTable.zd19;
                    test8 = currentTable.zd20;
                    test9 = currentTable.zd21;
                    $("#zd88").val(currentTable.zd88)
                    form.val('form-test', currentTable);
                }
            }});

        upload.render({
            elem: '#test1'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf,image/*,.rar,.zip'
            ,ext: 'rar|xls|xlsx|pdf|doc|docx|jpg|png|gif|bmp|jpeg'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input1").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test2'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf,image/*,.rar,.zip'
            ,ext: 'xls|xlsx|pdf|doc|docx|jpg|png|gif|bmp|jpeg'
            ,size:5120
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input2").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test3'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf,image/*,.rar,.zip'
            ,ext: 'xls|xlsx|pdf|doc|docx|jpg|png|gif|bmp|jpeg'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input3").val(res.obj);
                }
            }
        });
        // upload.render({
        //     elem: '#test4'
        //     ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
        //     ,accept: 'file' //普通文件
        //     ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf,image/*,.rar,.zip'
        //     ,ext: 'xls|xlsx|pdf|doc|docx|jpg|png|gif|bmp|jpeg'
        //     ,size:2048
        //     ,done: function(res){
        //         if (!res){
        //             layer.msg('请勿上传空文件！');
        //         }else {
        //             layer.msg('上传成功');
        //             $("#input4").val(res.obj);
        //         }
        //     }
        // });
        upload.render({
            elem: '#test55'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf,image/*,.rar,.zip'
            ,ext: 'xls|xlsx|pdf|doc|docx|jpg|png|gif|bmp|jpeg'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input55").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test41'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf,image/*,.rar,.zip'
            ,ext: 'xls|xlsx|pdf|doc|docx|jpg|png|gif|bmp|jpeg'
            ,size:5120
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input41").val(res.obj);
                }
            }
        });
        // upload.render({
        //     elem: '#test5'
        //     ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
        //     ,acceptMime: 'image/*',
        //     ext: 'jpg|png|gif|bmp|jpeg'
        //     ,multiple: true
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#demo5').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
        //         });
        //     }
        //     ,done: function(res){
        //         //上传完毕
        //         layer.msg('上传成功');
        //         if (test5 != ""){
        //             test5 = test5 + "," + res.obj;
        //         }else {
        //             test5 =  res.obj;
        //         }
        //     }
        // });
        //
        // upload.render({
        //     elem: '#test6'
        //     ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
        //     ,multiple: true
        //     ,acceptMime: 'image/*',
        //     ext: 'jpg|png|gif|bmp|jpeg'
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#demo6').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
        //         });
        //     }
        //     ,done: function(res){
        //         layer.msg('上传成功');
        //         if (test6 != ""){
        //             test6 = test6 + "," + res.obj;
        //         }else {
        //             test6 =  res.obj;
        //         }
        //     }
        // });
        // upload.render({
        //     elem: '#test7'
        //     ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
        //     ,multiple: true
        //     ,acceptMime: 'image/*',
        //     ext: 'jpg|png|gif|bmp|jpeg'
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#demo7').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
        //         });
        //     }
        //     ,done: function(res){
        //         layer.msg('上传成功');
        //         if (test7 != ""){
        //             test7 = test7 + "," + res.obj;
        //         }else {
        //             test7 =  res.obj;
        //         }
        //     }
        // });
        // upload.render({
        //     elem: '#test8'
        //     ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
        //     ,multiple: true
        //     ,acceptMime: 'image/*',
        //     ext: 'jpg|png|gif|bmp|jpeg'
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#demo8').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
        //         });
        //     }
        //     ,done: function(res){
        //         layer.msg('上传成功');
        //         if (test8 != ""){
        //             test8 = test8 + "," + res.obj;
        //         }else {
        //             test8 =  res.obj;
        //         }
        //     }
        // });
        // upload.render({
        //     elem: '#test9'
        //     ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
        //     ,multiple: true
        //     ,acceptMime: 'image/*',
        //     ext: 'jpg|png|gif|bmp|jpeg'
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#demo9').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
        //         });
        //     }
        //     ,done: function(res){
        //         layer.msg('上传成功');
        //         if (test9 != ""){
        //             test9 = test9 + "," + res.obj;
        //         }else {
        //             test9 =  res.obj;
        //         }
        //     }
        // });
        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1',
            value: new Date()
        });
        laydate.render({
            elem: '#date2',
            value: new Date()
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '请填写内容！';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                if(value.length < 18){
                    return '信用代码填写不正确！';
                }
            }
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            $('#tjsb').attr({'disabled':'disabled'});
            var obj1 = $("#example").serializeJSON()
            var obj = {};

            obj.zd13 = obj1.zd13
            obj.zd14 = obj1.zd14
            // obj.zd16 = obj1.zd16
            obj.zd24 = obj1.zd24
            obj.zd41 = obj1.zd41
            obj.zd88 = obj1.zd88
            // obj.zd17 = test5;
            // obj.zd18 = test6;
            // obj.zd19 = test7;
            // obj.zd20 = test8;
            // obj.zd21 = test9;
            obj.qyid = qyid;
            // if(test5==''||test6==''||test8==''){
            //     alert('请上传完整图片信息！')
            // }else {
            if(qyid){
                $.ajax({
                    type: "post",
                    url: ctx + "pv/cjqysqbs",
                    data: JSON.stringify(obj),
                    dataType:"json",
                    contentType:"application/json",
                    success: function(r) {
                        sb(qyid);
                        if (r.code != "200"){
                            layer.msg('提交失败');
                            $('#tjsb').removeAttr('disabled');
                        }
                    }
                });
            }else{
                alert("由于操作时间过长，请重新登录");
            }

            // }

            return false;
        })

    });
    //上报
    function sb(qyid) {
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            success: function(r) {
                if (r.code == "200") {
                    var data = r.data;
                    $.ajax({
                        type: "put",
                        url: ctx + "pv/qyxxs/" + qyid,
                        data: JSON.stringify({
                            "status": data.sflouyu === '1' ? '2' : '3'
                        }),
                        dataType: "json",
                        contentType: "application/json",
                        success: function (r) {
                            if (r.code == "200") {
                                layer.msg('上报成功！', {
                                    icon: 1,
                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                    window.location.href = "test.html"
                                });
                            } else {
                                layer.msg('上报失败');
                                $('#tjsb').removeAttr('disabled');
                            }
                        }
                    });
                }
            }});
    }

    //查看详情
    function ck(id) {
        layer.open({
            type: 2,
            title:"申报详情",
            content: 'testXq.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    //修改
    function xg(id) {
        layer.open({
            type: 2,
            title:"申报-修改",
            content: 'testXg.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    function checkStatus(cb) {
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            async: false,
            success: function(r) {
                if (r.code == "200"){
                    if (r.data.status >= 2) {
                        window.location.href = 'test.html'
                    } else {
                        if (cb) {
                            cb();
                        }
                    }
                }
            }
        });
    }

    function f(urls,id) {
        if (urls != null && urls != ""){
            var url = urls.split(",");
            $.each(url,function (i,u) {
                $('#'+id).append('<img src="'+ file + u +'" alt="'+ file + u +'" style = "width: 200px;" class="layui-upload-img">')
            })
        }
    }



</script>

</body>
</html>
